classdef Density < Processor
  % Class for Density
  % Derived from Processor
  % Constructor signature: D = Density(data, conn, S, T, P), 
  %     all args. optional
  %
  % Author: David Goldsmith, Wash. State Dept. of Ecology, dgol461@ecy.wa.gov
  % Release date: N/A
  
    properties
      % inherited from Processor
%         inData;
%         castDT;
%         scanRate;
%         ParamID;
%         ParamDesc;
%         SBEprec;
%         EquipID;
        DBdata;
        outData;% = struct('sigma_t', [], 'rho', []);
        rho;
    end
    
    methods
        function D = Density(data, conn, S, T, P) % Constructor
            global mSB
            
            if nargin < 1, data = []; end
            if nargin < 2, conn = []; end

            if nargin < 3, S = []; end
            
            if nargin < 4, T = []; 
            elseif mSB, T = 1.00024 * round2(T, 1e-4); % ITS90 => IPTS68
            else T = 1.00024 * T;
            end
            
            if nargin < 5, P = []; 
            elseif mSB, P = round2(P, 1e-3);
            end
            
            D = D@Processor(data);
            if ~isempty(conn), D.getDBdata(conn, 'D'); end
            if nargin==5
                D.mainFormula(S, T, P); 
            end
        end

        function mainFormula(obj, S, T, P)
            [obj.outData, obj.rho] = densityFunc(S, T, P); 
        end
        
        function delete(obj) % Destructor
            % Here in case I need it
        end
        
    end
    
end